import { createRouter, createWebHistory } from 'vue-router'


const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {path: '/',redirect: '/manager/test'},
    {path: '/manager',component: () => import('../views/Manager.vue'),children: [
        {path: 'home',name: 'home',component: () => import('../views/Home.vue'),},
        {path: 'test',name: 'test',component: () => import('../views/Test.vue'),},
        {path: 'data',name: 'data',component: () => import('../views/Data.vue'),},
      ]},
    // {path: '/',name: 'home',component: () => import('../views/Home.vue'),},
    // {path: '/test',name: 'test',component: () => import('../views/Test.vue'),},
  ],
})



//beforeEach 表示跳转之前的一些操作
router.beforeEach((to, from, next) => {
  document.title =to.meta.title // 设置标题
  next() //必须调用这个函数才能实现跳转
  // console.log(to, from)
  // console.log(to.path)
  // console.log(to.name)
  // console.log(to.fullPath)
  // console.log(to.query)
  // console.log(to.params)
  // console.log(to.meta)
  // console.log(to.matched)
  // console.log(to.redirectedFrom)
  // console.log(to.fullPath)
})
export default router
